<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ERP管理系统</title>
<link href="/login/style.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="/login/jquery.js"></script>
<script type="text/javascript" src="/login/cloud.js"></script>

<script language="javascript">
	$(function(){
    $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
	$(window).resize(function(){  
    $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
    })  
});  
</script> 
<script type="text/javascript">
	function resetErr() {
		$("#nameerr").hide();
		$("#nameerr").html("");
	}

	function reset() {
		$(':input,#loginform')
		 .not(':button, :submit, :reset, :hidden')
		 .val('')
	     .removeAttr('checked')
	     .removeAttr('selected');   
	}
	//按键事件
	document.onkeydown=keyDown;
	function keyDown(e){  
	    //IE内核浏览器  
	     if (navigator.appName == 'Microsoft Internet Explorer'){  
	           var keycode = event.keyCode;  
	           var realkey = String.fromCharCode(event.keyCode);  
	     }else {//非IE内核浏览器  
	           var keycode = e.which;  
	           var realkey = String.fromCharCode(e.which);  
	     }  
	   // console.log('按键码:' + keycode +  '字符: ' + realkey);  

	   //监听Ctrl键  
	   if(keycode==13){ 
		   if($("#icode").val() != null && $("#icode").val() != "" && $("#icode").val() != undefined) {
			   var icode =  $("#icode").val();
				$("#icode").val(icode+",");
			   return;
		   }
		   login();
	   }  
	}
	function login() {
		resetErr();
		if ($("#userName").val() == "" || $("#userName").val() == undefined
				|| $("#password").val() == ""
				|| $("#password").val() == undefined) {
			$("#nameerr").show();
			$("#nameerr").text("用户名或密码不得为空！");
		} else {
		$.ajax({
	            type: "POST",
	            url:"${pageContext.request.contextPath}/loginCheck.do",
	            data:$('#loginform').serialize(),// 你的formid
	            success: function(data) {
	            	if (data == 0) {
						$("#nameerr").show();
						$("#nameerr").html("用户名或者密码不正确！");
					}else {
						$("#login").attr("disabled", true); 
						
						var muban =$('input[name="radioId"]:checked').val();
						if(muban != null){
							window.location.href = muban;
						}else{
							$.ajax({
									type : "POST",
									url : "${pageContext.request.contextPath}/login.do",
									success : function(data) {
										window.location.href = data+ ".jsp";
									}
							});
						}
					}
	            }
	        }); 
		}
	}
</script>
</head>
<body style="background-color:#1c77ac; background-image:url(${pageContext.request.contextPath }/css/login/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;">

    <div id="mainBody">
      <div id="cloud1" class="cloud"></div>
      <div id="cloud2" class="cloud"></div>
    </div>  

<div class="logintop">    
    <!-- <span>欢迎登录后台管理界面平台</span>    
    <ul>
    <li><a href="#">回首页</a></li>
    <li><a href="#">帮助</a></li>
    <li><a href="#">关于</a></li>
    </ul>   -->  
    </div>
    
    <div class="loginbody">
    	
   		<span class="systemlogo"></span> 
    
  		 	<div class="loginbox">
   
		    <ul>
		    	<form id="loginform" class="form form-horizontal">  
				    <li><input id="userName" name="staffnumbering"  type="text" class="loginuser" placeholder="输入员工编号"/></li>
				    <li><input id="password" name="passwords" type="password" class="loginpwd" placeholder="输入密码"/></li>
				    <li style="margin-left: 35px">
				    	<input type="radio"  name="radioId" value="pages/jyy/work/allw1.jsp" title="按个扫码"/>
				    	<span style="display: inline-block;width: 90px;">按个扫码</span>
				    	<input type="radio"  name="radioId" value="pages/jyy/work/allw2.jsp" title="按箱扫码"/>
				    	<span style="display: inline-block;width: 90px;">按箱扫码</span>
				    	<input type="radio"  name="radioId" value="pages/lz/scanCode.jsp" title="扫码"/>
				    	<span style="display: inline-block;width: 90px;">绑定台车</span>
				    </li>
				 </form>
			    <div id="nameerr" style="color: red; margin-left: 90px;margin-bottom: 10px; "></div>
			    <li style="padding-left: 20px;">
			    	<input id="login" onclick="login()" type="button" class="loginbtn" value="登录"/>
			    	<input style="margin-left: 80px;" onclick="reset()" id="reset" type="button" class="loginbtn" value="重置"/>
			    </li>
		    </ul>
   		</div>
    </div>
    
    <div class="loginbm">Copyright ©2018 北京盛达融元西安研发中心</div>
</body>

</html>
